'''
作业
'''
from random import randint


# 1.
class Auto:
    def __init__(self, tire=4, color='white', weight=1, speed=180):
        self.tire = tire
        self.color = color
        self.weight = weight
        self.speed = speed

    @classmethod
    def ac(cls):
        print('加速')

    @classmethod
    def dec(cls):
        print('减速')

    @classmethod
    def stop(cls):
        print('停车')


class AirConditioner:
    def __init__(self, brand='geli', power=1, type='wc'):
        self.brand = brand
        self.power = power
        self.type = type


class CD:
    def __init__(self, brand='sony', color='black', price=1000):
        self.brand = brand
        self.color = color
        self.price = price


class CarAuto(Auto):
    def __init__(self, tyre=4, color='white', weight=2, speed=0):
        super().__init__(tyre, color, weight, speed)
        air = 'air'
        cd = 'CD'

    @classmethod
    def ac(cls):
        print('son加速')

    @classmethod
    def dec(cls):
        print('son减速')

    @classmethod
    def stop(cls):
        print('son停车')


# 2.
class Person:
    count = 0

    def __init__(self):
        if self.__class__ == 'Person':
            Person.count += 1


p1 = Person()
p2 = Person()
print(Person.count)


# 3.
class Animal:
    def __init__(self, gender='1', age=2, color='white', breed='bird'):
        self.gender = gender
        self.age = age
        self.color = color
        self.breed = breed

    def __repr__(self):
        return '/{}的对象: 性别-{} 年龄-{} 颜色-{} 类型-{}/'.format(Animal.__name__, self.gender, self.age, self.color, self.breed)


b = Animal()


# 4.
class CircleError:
    def __str__(self):
        return '该属性不能赋值'


class Circle:
    pi = 3.1415926

    def __init__(self, r):
        self.r = r
        self._area = 0
        self._per = 0

    @property
    def area(self):
        return Circle.pi * self.r * self.r

    @area.setter
    def area(self, value):
        raise CircleError

    @property
    def per(self):
        return Circle.pi * self.r * 2

    @per.setter
    def per(self, value):
        raise CircleError


c1 = Circle(3)
print(c1.area, c1.per)


# 5.
class Poker:
    def __init__(self):
        self.pokers = []
        for one in range(1, 13):
            self.pokers.append(one)

    def deal(self):
        for one in self.pokers:
            yield one

    def shuffle(self):
        print(set(self.pokers))


p3 = Poker()
print(p3.pokers)
p3.shuffle()

# class A(Poker):
#     num = 13
#
#     def __init__(self):
#         self._aa = 0
#
#     @property
#     def aa(self):
#         a = randint(1, 13)
#         return 'a' + str(a)
#
#
# a1 = A()
# print(a1.aa)
